<template>
  <!-- 底部部分 -->
  <footer class="footer" v-show="this.list.length > 0 ? true : false">
    <span class="todo-count"
      ><strong>{{ count }}</strong
      >剩余</span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: type === 'all' }"
          href="#/"
          @click="filterType('all')"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: type === 'active' }"
          href="#/active"
          @click="filterType('active')"
          >进行中</a
        >
      </li>
      <li>
        <a
          :class="{ selected: type === 'completed' }"
          href="#/completed"
          @click="filterType('completed')"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-show="show" @click="clearDone">
      清除已完成
    </button>
  </footer>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      required: true,
    },
    type: {
      type: String,
    },
  },
  computed: {
    count() {
      return this.list.filter((item) => {
        return item.isDone == false
      }).length
    },
    show() {
      return this.list.some((item) => item.isDone)
    },
  },
  methods: {
    clearDone() {
      this.$emit('clearDone')
    },
    filterType(type) {
      this.$emit('gaoliang', type)
    },
  },
  // data() {
  //   return {
  //     type: 'all',
  //   }
  // },
}
</script>
